package com.retail.lottery.colalottery.job.db;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.sql.*;

@Component
@Slf4j
public class CheckFlywayData {

    //@PostConstruct
    public void init() {
        executeQuery();
    }

    public void executeQuery() {
//
//        // SQL查询语句
//        //String query = "SELECT * FROM flyway_schema_history"; // 替换为你的表名
//        String query = "Delete FROM flyway_schema_history where version = '4'"; // 替换为你的表名
//
//        // 使用try-with-resources语句自动关闭资源
//        try (Connection connection = DriverManager.getConnection(url, user, password);
//             Statement statement = connection.createStatement();
//             //ResultSet resultSet = statement.executeQuery(query)
//        ) {
//            statement.execute(query);
//            // 处理查询结果
////            while (resultSet.next()) {
////                // 假设表中有两列：id 和 name，你可以这样获取值
////                int success = resultSet.getInt("success"); // 或者使用 resultSet.getInt(1);
////                String version = resultSet.getString("version"); // 或者使用 resultSet.getString(2);
////                String description = resultSet.getString("description"); // 或者使用 resultSet.getString(2);
////                String script = resultSet.getString("script"); // 或者使用 resultSet.getString(2);
////                log.info("version: " + version+ ", description: " + description+ ", script: " + script+ ", success: " + success);
////            }
//            log.info("删除成功");
//        } catch (SQLException e) {
//            e.printStackTrace();
//            log.info("删除失败");
//        }
    }
}
